// constcast.cpp -- using const_cast<>
#include <iostream>
using std::cout;
using std::endl;

class Height
{
private:
    /* data */
public:
    Height(/* args */);
    ~Height();
};

Height::Height(/* args */)
{
}

Height::~Height()
{
}

class Low:Height
{
private:
    /* data */
public:
    Low(/* args */);
    ~Low();
};

Low::Low(/* args */)
{
}

Low::~Low()
{
}


void change(const int * pt, int n);

int const_cast_main()
{
    Height bar;
    const Height *pbar = &bar;

    Height *pb = const_cast<Height *> (pbar);
    // error: const_cast from 'const Height *' to 'Low *' is not allowed
    // const Low *pl = const_cast<Low *>(pbar);
    // const Low *pl = const_cast<const Low *>(pbar);
    
    int pop1 = 38383;
    const int pop2 = 2000;

    cout << "pop1, pop2: " << pop1 << ", " << pop2 << endl;
    change(&pop1, -103);
    change(&pop2, -103);
    cout << "pop1, pop2: " << pop1 << ", " << pop2 << endl;
    // std::cin.get();
    return 0;
}

void change(const int * pt, int n)
{
    int * pc;
  
    pc = const_cast<int *>(pt);
    *pc += n;
 
}
